/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package batailledesardennes.game.ui;

import batailledesardennes.game.GameConstants;
import batailledesardennes.game.interfaces.Drawable;
import batailledesardennes.util.geomFloat.Rectangle;
import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;

/**
 *
 * @author charly
 */
public class SelectionDrawable implements Drawable {
   private boolean active;
   private int anchorX;
   private int anchorY;
   private int x;
   private int y;

   @Override
   public void draw(Graphics g) {
      if (!active) {
         return;
      }
      g.setColor(Color.white);
      g.drawRect(getLeftX(), getTopY(), getWidth(), getHeight());
   }

   public void setActive(boolean active) {
      this.active = active;
   }

   public void setAnchorX(int anchorX) {
      this.anchorX = anchorX;
   }

   public void setAnchorY(int anchorY) {
      this.anchorY = anchorY;
   }

   public void setX(int x) {
      this.x = x;
   }

   public void setY(int y) {
      this.y = y;
   }

   public int getLeftX() {
      return Math.min(x, anchorX);
   }

   public int getTopY() {
      return Math.min(y, anchorY);
   }

   public int getWidth() {
      return Math.abs(x - anchorX);
   }

   public int getHeight() {
      return Math.abs(y - anchorY);
   }

   @Override
   public short getDrawablePriority() {
      return GameConstants.DRAWABLE_PRIORITY_BACK;
   }
}
